package com.cskaoyan.javase.exception._2finally;

/**
 * @description: try...catch变形
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * > try...catch变形
 *
 * - try...catch...finally
 * - try...catch...
 * - try...catch...catch...
 * - try...catch...catch...finally
 *   - 以上都是常见形式
 * - try...finally
 *   - 该形式在不需要捕获异常，但是希望使用finally代码块的场景中使用
 *
 *
 */
public class Demo2 {
    public static void main(String[] args) {
        try {
            test();
        } catch (ArithmeticException e) {
            e.printStackTrace();
        }

        System.out.println("xxxx");
    }

    public static void test(){
        //如果在方法内部不想捕获处理异常,但是又有资源需要释放,或者有无论程序怎么执行都要运行的代码,这时候就可以try...finally
        try {
            System.out.println(10/0);
        } finally {
            System.out.println("这是我必须要完成的事情!");
        }
    }
}
